<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务对账单" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintExt()");
	}
	function doPrintExt(){
		if(popRetVal!=null){
			var len=${itemTotal};
			var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
			document.getElementById("noPrinSpan").style.display="none";
			if(len>200 && isIE){
				iePrint("wb","${enterpriseInfo.doPrint}");
			}else{
				printContent("管理易-业务对账单","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}");
			}
			document.getElementById("noPrinSpan").style.display="";
		}
	}
	function doCancel(){
		window.location="/online/BusiAccoForm.ihtm";
	}
	function doDownload(type){
		var str=getSearchCondiction();
		window.location='/online/BusiAcco.ihtm?content_type='+type+'&'+str;
	}
	function getSearchCondiction(){
		var startDate="${start_date}";
		var endDate="${end_date}";
		return '&start_date='+startDate+'&end_date='+endDate;
	}
</script>
</head>
<body style="background-color:#FFFFFF">
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td width="16%"><img src="${enterpriseInfo.loginImage}" /></td>
					<td width="68%" height="40px" align="center" class="FontLarge_Bold">${licenseInfo.enterpriseName} 业务对账单</td>
					<td width="16%">&nbsp;</td>
				</tr>
		  </table>			
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="35%">&nbsp;订货单位：${record[1].estName}(包括下属单位)</td>
			      	<td class="FontSmall" width="40%">&nbsp;日期：&nbsp;${start_date} 至 ${end_date}</td>
					<td class="FontSmall" width="25%" >&nbsp;合同金额：&nbsp;${record[3]}</td>
				</tr>
				<tr class="ListTrPrint">
			      	<td class="FontSmall">&nbsp;已收金额：&nbsp;${record[4]}</td>
					<td class="FontSmall">&nbsp;调账金额：&nbsp;${record[5]}</td>
			      	<td class="FontSmall">&nbsp;尚欠金额：&nbsp;${record[7]}</td>		      	
				</tr>	
				<tr class="ListTrPrint">
			      	<td class="FontSmall">&nbsp;地址：&nbsp;${record[1].address}</td>
					<td class="FontSmall">&nbsp;联系人：&nbsp;${record[2].contactName}</td>
			      	<td class="FontSmall">&nbsp;电话：<c:if test="${record[2].phone!=null && record[2].phone!=''}">&nbsp;${record[2].phone}</c:if><c:if test="${record[2].mobile!=null && record[2].mobile!=''}">&nbsp;${record[2].mobile}</c:if></td>		      	
				</tr>							  
		  </table>			
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
                    <td width="3%" class="FontSmall_Bold"><div align="center">序号</div></td>
					<td width="8%" class="FontSmall_Bold"><div align="center">日期</div></td>
					<td width="8%" class="FontSmall_Bold"><div align="center">单号</div></td>
					<td width="7%" class="FontSmall_Bold"><div align="center">项目类型</div></td>
					<td width="9%" class="FontSmall_Bold"><div align="center">内容</div></td>
					<td width="10%" class="FontSmall_Bold"><div align="center">材质</div></td>
					<td width="14%" class="FontSmall_Bold"><div align="center">规格</div></td>
					<td width="5%" class="FontSmall_Bold"><div align="center">单位</div></td>
					<td width="5%" class="FontSmall_Bold"><div align="center">数量</div></td>
					<td width="6%" class="FontSmall_Bold"><div align="center">单价</div></td>
					<td width="7%" class="FontSmall_Bold"><div align="center">金额</div></td>
					<td width="10%" class="FontSmall_Bold"><div align="center">制作要求</div></td>
					<td width="8%" class="FontSmall_Bold"><div align="center">部门/经手人</div></td>
				</tr>
				<c:set var="preBillId" value="0" />
				<c:forEach var="item" items="${record[0]}" varStatus="i">
				<c:set var="styleStr" value="style='color:blue'" />
				<c:if test="${item[8]!=0.00}"><c:set var="styleStr" value="style='font-weight:bold;color:blue'" /></c:if>
				<c:if test="${item[6]=='Y'}"><c:set var="styleStr" value="style='font-weight:bold;color:red'" /></c:if>
				<tr class="ListTrPrint" ${styleStr}>
					<td class="FontSmall" align="center">${i.index+1}</td>
					<td class="FontSmall" align="center">
						<c:if test="${preBillId!=item[0].billId}"><fmt:formatDate value="${item[3]}" pattern="yyyy-MM-dd"/></c:if>
					</td>
					<td class="FontSmall" align="center">
						<c:if test="${preBillId!=item[0].billId}"><a href="javascript:showRelBill('${item[2]}');">${item[2]}</a></c:if>
					</td>
					<td class="FontSmall" align="center"><commonTag:showSimpleObjectName list="${mtList}" objectId="${item[0].makeTypeId}" /></td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[0].finishedContent}" /></td>
					<td class="FontSmall" align="center">${item[0].proName}</td>
					<td class="FontSmall" align="center">
						<commonTag:parseEnterToBr source="${item[0].specification}" />
						<c:if test="${item[0].priceType=='AREA' || item[0].priceType=='LENGTH'}"> x <commonTag:parseBigDecimal source="${item[0].amount}" /></c:if>
					</td>
					<td class="FontSmall" align="center">
						<c:if test="${item[0].priceType=='AREA'}">平方米</c:if>
						<c:if test="${item[0].priceType=='LENGTH'}">
							<c:if test="${item[0].lengType=='M'}">米</c:if><c:if test="${item[0].lengType=='CM'}">公分</c:if>
						</c:if>
						<c:if test="${item[0].priceType=='AMOUNT'}">${item[0].unit}</c:if>
					</td>
					<td class="FontSmall">
					<div align="right">
						<c:if test="${item[0].priceType=='AREA' || item[0].priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item[0].squareNum}" /></c:if>
						<c:if test="${item[0].priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item[0].amount}" /></c:if>
					</div>
					</td>
					<td class="FontSmall"><div align="right"><commonTag:parseBigDecimal source="${item[0].unitPrice}" /></div></td>
					<td class="FontSmall"><div align="right"><commonTag:parseBigDecimal source="${item[0].cost}" /></div></td>
					<td class="FontSmall"><div align="center"><commonTag:parseEnterToBr source="${item[0].makeRequire}" /></div></td>
					<td class="FontSmall" align="center">
                        <c:if test="${preBillId!=item[0].billId}">
                        	<c:if test="${record[1].estName!=item[1]}">${item[1]}</c:if>
                        	${item[5]}
                        </c:if>
					</td>
				</tr>
				<c:if test="${preBillId!=item[0].billId}"><c:set var="preBillId" value="${item[0].billId}" /></c:if>
				</c:forEach>
				<tr class="ListTrPrint" ><td colspan="13" class="FontSmall" align="right"><c:if test="${record[6]!=0.00}">小计金额：${record[3]+record[6]}元&nbsp;扣除优惠金额：${record[6]}元&nbsp;</c:if>合同金额：${record[3]}元</td></tr>
			</table>
			
		</td>
	</tr>
	<c:if test="${codeRule.printFoot!=null && codeRule.printFoot!=''}">
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td class="FontSmall"><commonTag:parseEnterToBr source="${codeRule.printFoot}" /></td>
				</tr>
			</table>
		</td>
	</tr>
	</c:if>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="noPrinSpan">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td>
						<input type="button" id="printButton" class="Button" value="开始打印" onClick="doPrint();">
						<input type="button" id="printButton" class="Button" value="导出完整数据 " onClick="doDownload('EXCEL');">
						<input type="button" id="printButton" class="Button" value="导出打印格式 " onClick="doDownload('EXCEL_PRINT');">
						<input type="button" id="cancelButton" class="Button" value=" 返 回 " onClick="doCancel();">
					</td>
				</tr>
				<tr>
					<td class="FontSmall" style="color:grey">注：红色表示无欠款，加粗蓝色表示已部分付款，蓝色表示无付款</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>
